﻿// See https://aka.ms/new-console-template for more information
using DataStandard;
using DataStandard.ProtocoType;
using JieKou.Modbus;

Console.WriteLine("Hello, World!");


ProtocolItem protocolItem = new ProtocolItem();
protocolItem.Name = "测试ProtocolItem";

JieKou.Modbus.ParameterTCP parameterTCP = new JieKou.Modbus.ParameterTCP();
parameterTCP.Index = 0;
parameterTCP.IsContinuously = false;
parameterTCP.ModbusName = "测试ModbusTCP连接";
parameterTCP.RemoteIP = "127.0.0.1";
parameterTCP.RemotePort = 502;
parameterTCP.RemoteID = 1;
parameterTCP.ModbusTimeOut = 1000;
parameterTCP.Functioncode = 3;
protocolItem.ChooseIniInterfaceType(parameterTCP);

DataItem item = new DataItem();
item.ParentName = protocolItem.Name;
item.Functioncode = ((ModbusQi)protocolItem.InterfaceType).FunctionCode;

var description = new DataItemDescription();
description.Name = "测试数据1";
description.Unit = "kW";
description.Type = "UINT16";
description.UnitIdentifier = 1;
description.RegisterOrder = "12";
description.BitIndex = -1;
description.Multiple = 1;
description.Offset = 0;
description.SettingTimer = 1000;


item.Description = description;
protocolItem.AddDataItem(item);
((ModbusQi)protocolItem.InterfaceType).IsAutoReRun = true;

protocolItem.Run();

Console.ReadLine();